package com.skyline.base.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.skyline.base.model.Comment;


/**
 * 评论的mapper
 * 
 * @author Jairus Chan
 * @version 0.1
 * */
public class CommentMapper implements RowMapper<Comment> {
	
	private static final CommentMapper MAPPER = new CommentMapper();
	public static CommentMapper getMapper() {
		return MAPPER;
	}

	public Comment mapRow(ResultSet rs, int rowNum) throws SQLException {
		Comment c = new Comment();
		c.setId(rs.getLong("id"));
		c.setContent(rs.getString("content"));
		c.setCreateTime(rs.getTimestamp("createtime"));
		c.setCommenterId(rs.getLong("commenterId"));
		c.setCommenterNickname(rs.getString("commenterNickname"));
		c.setCommenterPortrait(rs.getString("commenterPortrait"));
		c.setRef(rs.getLong("ref"));
		c.setResourceId(rs.getLong("resourceId"));
		c.setOwnerId(rs.getLong("ownerId"));
		c.setAgreeNum(rs.getInt("agreeNum"));
		c.setDisagreeNum(rs.getInt("disagreeNum"));
		return c;
	}
}
